<template>
  <div class='confirm-order-container'>
    <h2>订单详情</h2>
    <!-- <div class="step-container">
      <el-steps :active="0"
                finish-status="success"
                align-center>
        <el-step title="确认订单">
        </el-step>
        <el-step title="支付">
        </el-step>
        <el-step title="支付成功">
        </el-step>
      </el-steps>
    </div> -->

    <div class="delivery-address-container">
      <div class="delivery-address-info">
        <p>
          <i>收货人：</i> {{choosenAddressData.recive_user}}
        </p>
        <p class="phone">
          <i>手机号：</i> {{choosenAddressData.phone}}
        </p>
        <p class="address">
          <i>收货地址：</i> {{choosenAddressData.province}} {{choosenAddressData.city}} {{choosenAddressData.area}} {{choosenAddressData.recive_addr}}
        </p>
        <p style="color: #999;font-size:14px;"><i>关联项目:</i></p>
        <!-- <span @click="chooseAddressDialogVisible=true"
              class="choose-address">选择地址</span> -->
      </div>
    </div>
    <div class="product-info-container">
      <h2>产品信息</h2>
      <ul class="product-info-list">
        <li class="info-list-item"
            v-for="(item, index) in choosenAddressData.product_list"
            :key="index">
          <img :src="item.product_img"
               alt="">
          <div class="product-detail-container">
            <div class="product-info">
              <p class="product-name">{{item.product_name}}</p>
              <p class="product-description">{{item.product_desc}}</p>
            </div>
            <div class="product-info flex-end">
              <span class="product-price">
                ￥{{(item.price/100).toFixed(2)}}
              </span>
              <span class="product-num">数量：{{item.num}}</span>
            </div>

          </div>

        </li>
      </ul>
    </div>
    <!-- <div class="order-info-container">
      <div class="order-info total-price">
        <i>商品总额：</i>
        <span>￥{{totalPrice}}</span>
      </div>
      <div class="order-info transport-fee">
        <i>运费：</i>
        <span>￥{{transportFee}}</span>
      </div>
      <div class="order-info">
        <i>应付金融：</i>
        <span class="should-pay">￥{{actualPrice}}</span>
      </div>
    </div>
    <div style="text-align:right;margin:20px 0px;">
      <el-button type="primary"
                 @click="submitOrder">去支付</el-button>
    </div> -->
    <div class="delivery-address-container">
      <!-- <h2>
        订单结算
        <span @click="addAddressDialogVisible=true">添加地址</span>
      </h2> -->
      <div class="delivery-address-info">
        <p>
          <i>商品总额：</i> {{choosenAddressData.orderMoney}}
        </p>
        <p class="phone">
          <i>运费：</i> 到付
        </p>
        <p class="address"
           style="font-size:14px;">
          <i style="color: #999;">应付金额：</i> ￥{{choosenAddressData.orderMoney}}
        </p>
      </div>
    </div>
    <div class="delivery-address-container">
      <!-- <h2>
        支付情况
        <span @click="addAddressDialogVisible=true">添加地址</span>
      </h2> -->
      <div class="delivery-address-info">
        <p>
          <i>支付方式：</i> 支付宝
        </p>
        <p class="phone">
          <i>支付金额：</i> ￥{{choosenAddressData.payMoney}}
        </p>
        <p class="address"
           style="font-size:14px;">
          <i style="color: #999;">支付时间：</i> {{choosenAddressData.pay_date}}
        </p>
      </div>
    </div>
  </div>
</template>
<script>
import { orderListApi } from '@/services/PersonalCenter'
export default {
  data () {
    return {
      // 添加地址弹框是否可见
      addAddressDialogVisible: false,
      // 添加地址表单对象
      addAddressForm: {
        recive_user: '',
        recive_addr: '',
        recive_phone: '',
        province: '',
        province_no: '',
        city: '',
        city_no: '',
        area: '',
        area_no: '',
        verify_code: ''
      },
      // 添加地址表单验证规则
      addAddressFormRules: {
        recive_user: [
          { required: true, message: '请输入收货人', trigger: 'blur' }
        ],
        recive_phone: [
          { required: true, message: '请输入手机号', trigger: 'blur' }
        ],
        verify_code: [
          { required: true, message: '请输入验证码', trigger: 'blur' }
        ],
        recive_addr: [
          { required: true, message: '请输入具体位置', trigger: 'blur' }
        ]
      },
      // 选择地址弹框是否可见
      chooseAddressDialogVisible: false,
      // 已创建地址列表
      addressList: [],
      // 已选择的地址对象
      choosenAddressData: {

      },
      choosenAddressDataTemp: {

      },
      // 省市区数据
      addressOptions: [],
      provinceList: [],
      cityList: [],
      areaList: [],
      province: {},
      city: {},
      area: {},
      productCart: [
        { id: '1', product_name: '北斗定位终端', product_desc: '车辆运输过程', product_price: 100, num: 300 }
      ],
      uuid: this.$route.query.uuid,
      // 收到的验证码
      verifyCode: '',
      // 创建订单对象
      submitOrderInfo: {
        recive_addr_id: ''
      },
      // 选中的地址id
      choosenAddressId: '',
      // 订单总额
      totalPrice: 0,
      // 运费
      transportFee: 0,
      // 应付金额
      actualPrice: 0
    }
  },
  methods: {
    // 提交订单
    submitOrder () {

    },
    getOrderDetail () {
      orderListApi.getOrderDetail({
        params: {
          uuid: this.uuid,
          order_id: this.$route.query.order_id
        }
      }).then((res) => {
        this.choosenAddressData = res.data
        this.choosenAddressData.phone = this.choosenAddressData.recive_phone.substring(0, 3) + '****' + this.choosenAddressData.recive_phone.substring(7, 11)
        this.choosenAddressData.orderMoney = (this.choosenAddressData.order_money / 100).toFixed(2)
        this.choosenAddressData.payMoney = (this.choosenAddressData.pay_money / 100).toFixed(2)
      }).catch((error) => {
        console.log(error)
      })
    }
  },
  created () {
    this.getOrderDetail()
  },
  mounted () {
  }
}
</script>
<style scoped lang='scss'>
@function p2vw($size) {
  @return ($size/1440) * 100vw;
}
.col-3 {
  width: 25%;
}
.col-4 {
  width: 33.33%;
}
.confirm-order-container {
  p {
    margin: 0;
  }
  i {
    font-style: normal;
  }
  > h2 {
    height: 50px;
    line-height: 50px;
    padding-left: 20px;
    font-size: 16px;
    color: #1441b3;
    border-bottom: 1px solid #d9d9d9;
  }
  .step-container {
    width: 500px;
    margin: 0 auto;
  }
  .delivery-address-container {
    margin: 50px 0 30px;
    padding: 0 20px;

    h2 {
      font-size: 14px;
      color: #333;
      margin: 0;
      margin-bottom: 20px;
      span {
        font-size: 14px;
        color: #40a9ff;
        float: right;
        cursor: pointer;
      }
    }
    .delivery-address-info {
      border-bottom: 1px solid #e6e6e6;
      padding-bottom: 20px;
      p:not(:last-child) {
        margin-bottom: 12px;
        font-size: 14px;
        color: #333;
        i {
          color: #999;
        }
      }
      .choose-address {
        font-size: 14px;
        color: #1441b3;
        margin-top: 20px;
        cursor: pointer;
      }
    }
  }
  .product-info-container {
    padding: 0 20px;
    h2 {
      margin: 0;
      margin-bottom: 20px;
      font-size: 14px;
      color: #333;
    }
    .product-info-list {
      border-bottom: 1px solid #e6e6e6;
      .info-list-item {
        display: flex;
        align-items: center;
        margin-bottom: 20px;
        img {
          width: 60px;
          height: 60px;
          border: 1px solid #000;
          margin-right: 20px;
        }
        .product-detail-container {
          display: flex;
          flex-grow: 1;
          justify-content: space-between;
          align-items: center;
          .product-info {
            display: flex;
            flex-direction: column;
            justify-content: flex-start;
            &.flex-end {
              justify-content: flex-end;
            }
            .product-name {
              font-size: 14px;
              color: #333;
              margin-bottom: 12px;
            }
            .product-description {
              font-size: 12px;
              color: #999;
            }
            .product-num {
              font-size: 12px;
              color: #999;
              text-align: right;
            }
            .product-price {
              font-size: 18px;
              color: #ff4d4f;
              margin-bottom: 12px;
            }
          }
        }
      }
    }
  }
  .order-info-container {
    padding: 20px 20px 0;
    .order-info {
      display: flex;
      justify-content: flex-end;
      align-items: center;
      &:last-child {
        border-bottom: 1px solid #e6e6e6;
        padding-bottom: 20px;
      }
      i {
        font-size: 14px;
        color: #999;
        text-align: right;
        margin-right: 100px;
      }
      span {
        font-size: 14px;
        color: #333;
        width: 100px;
        text-align: right;
        &.should-pay {
          font-size: 18px;
          color: #ff4d4f;
        }
      }
    }
    .total-price {
      margin-bottom: 12px;
    }
    .transport-fee {
      margin-bottom: 20px;
    }
  }
  .rule-container {
    display: flex;
    justify-content: flex-end;
    padding: 0 20px;
    margin-top: 40px;
    span {
      font-size: 14px;
      color: #666;
      i {
        color: #333;
      }
    }
  }
  .submit-order-container {
    display: flex;
    margin-top: 20px;
    padding: 0 20px;
    justify-content: flex-end;
    button {
      width: 96px;
      height: 36px;
      border: 0;
      border-radius: 4px;
      background: #1890ff;
      color: #fff;
      font-size: 14px;
      line-height: 36px;
    }
  }
  .choose-address-list {
    .choose-address-item {
      display: flex;
      align-items: center;
      padding: 0 20px;
      margin-bottom: 12px;
      .choose-checkbox {
        margin-right: 20px;
      }
      .address-info {
        display: flex;
        width: 384px;
        height: 76px;
        flex-direction: column;
        justify-content: center;
        border-radius: 4px;
        padding: 0 20px;
        border: 1px solid #bfbfbf;
        &.choosen {
          border: 1px solid #1890ff;
        }
        .recive-name {
          font-size: 14px;
          color: #333;
          margin-bottom: 12px;
          font-weight: bold;
          .recive-phone {
            font-weight: normal;
          }
        }
        .recive-address {
          color: #333;
          font-size: 12px;
        }
      }
    }
  }
  .add-address-form {
    .el-input-group {
      button.el-button {
        background-color: #409eff;
        color: #fff;
        border: 0;
        border-radius: 0;
      }
    }
  }
}
</style>
